<?php

namespace App\Models\Scm;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;

class ParkingPermitVehicle extends Model
{
    use HasFactory, SoftDeletes, HasDateTimeFormatter;

    /**
     * table name
     * @var string
     */
    protected $table = 'scm_parking_permit_vehicles';

    /**
     * json <=> array
     * @var string[]
     */
    protected $casts = [
        'extra_data' => 'array',
    ];

    public function parking_permit(): HasOne
    {
        return $this->hasOne(ParkingPermit::class, 'id', 'parking_permit_id');
    }

    public function vehicle(): HasOne
    {
        return $this->hasOne(Vehicle::class, 'id', 'vehicle_id');
    }
}
